<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>

<script type="text/javascript">
	function sparepartCategoryTree_onNodeClick(event, treeId, treeNode) {

		sparepartGrid.search({
			"field" : "treenode_path",
			"op" : "bw",
			"data" : treeNode.treenodePath
		});
	}
	
	function getSparepartCategoryTreeNode() {
		var nodes = sparepartCategoryTree.zTree.getSelectedNodes();

		if (nodes  && nodes != "") {
			return "categoryId=" + nodes[0].id;
		}
		
		isperp.alert("请选择备件分类！");
		return false;
	}
</script>


	<div id="dvFrameMainNav" class="frame-main-nav" style="position:fixed">	
		<isperp:tree title="备件分类" modal="false" id="sparepartCategoryTree"
			cusEditUrl="sparepart/category/edit"
			cusDeleteUrl="sparepart/category/delete">
			<isperp:async enable="true" url="sparepart/category/getTree?showRoot=1">
			</isperp:async>
			<isperp:callback onClick="sparepartCategoryTree_onNodeClick">
		  </isperp:callback>
			<isperp:edit enable="true" showRemoveBtn="false"
				showRenameBtn="false"></isperp:edit>
			<isperp:view showTitle="false" addHoverDom="true"
				removeHoverDom="true"></isperp:view>
		</isperp:tree>
	</div>
	<div class="box-right">
		<div class="box no-border">
			<div class="header">
				<h2>备件产品列表</h2>
			</div>
			<isperp:grid gridId="sparepartGrid"
				url="sparepart/sparepart/old/listDetail" gridTitle="${pageTitle}"
				cusEditUrl="sparepart/sparepart/old/edit" cusFormatterActions="true"
				cusDeleteUrl="sparepart/sparepart/delete" actionsWidth="90"
				ondbClickRowEvent="sparepartGrid.edit(rowid);" sortname="code" 
				beforeCreateAction="getSparepartCategoryTreeNode();">
				<jsp:attribute name="searchbar">	
				<table class="form-table">
						<tbody>
							<tr>
								<td align="right">编号：</td>
								<td><input type="text" field="code" op="cn">
								</td>
								<td align="right">名称：</td>
								<td><input type="text" field="name" op="cn">
								</td>
								<td align="right">型号：</td>
								<td><input type="text" field="model" op="cn">
								</td>
							</tr>
						</tbody>
					</table> 
				</jsp:attribute>
				<jsp:attribute name="toolbar">
				<isperp:toolbar id="userToolbar">
					<isperp:button id="sparepartGridCeate" icon="icon-plus" text="新增备件产品"
							cssClass="nui-mainbtn" onclick="sparepartGrid.create();"></isperp:button>
				</isperp:toolbar>	
				</jsp:attribute>
				<jsp:body> 
					<isperp:column name="id" title="id" hidden="true"></isperp:column> 
					<isperp:column name="code" title="编号" width="120">
					</isperp:column>
					<isperp:column name="name" title="名称" width="100">
					</isperp:column> 
					<isperp:column name="model" title="型号" width="100">
					</isperp:column> 
					<isperp:column name="unit" title="单位" width="60">
					</isperp:column> 
					<isperp:column name="min_stock_result" title="最小库存" width="80">
					</isperp:column>
					<isperp:column name="cur_stock_quantity" title="当前库存" width="80">
					</isperp:column>
					<isperp:column name="treenode_name_path" title="备件分类" width="120">
					 </isperp:column>
					 
			</jsp:body>
			</isperp:grid>
		</div>
		<isperp:operate code="COMMON_TREE_LIST_HELP"></isperp:operate>
	</div>
